package org.jsemantic.support.examples.even;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Random;

import org.jservicerules.support.semanticservice.StatelessSemanticService;
import org.jservicerules.support.spring.SpringContextFactory;
import org.springframework.context.ApplicationContext;

public class EvenApplication {

	private static final org.apache.log4j.Logger log = org.apache.log4j.Logger
			.getLogger(EvenApplication.class);

	private static ApplicationContext ctx = SpringContextFactory
			.getClassPathApplicationContexFactory("org/jsemantic/support/examples/even/services.xml");

	public static void main(String args[]) {

		StatelessSemanticService service = (StatelessSemanticService) ctx
				.getBean("evenService");
		Collection result = service.execute(getFacts());

		if (log.isInfoEnabled()) {
			log.info(result);
		}
	}

	private static Collection getFacts() {
		Random r = new Random();
		List facts = new ArrayList();
		for (int i = 0; i < 10; i++) {
			facts.add(new Integer(r.nextInt() % 100));
		}
		return facts;
	}
}
